<template>
  <div id="feedBack" class="person-detail">
    <div>
      <van-nav-bar title="我的投递" :fixed="true" left-arrow @click-left="back" />
    </div>
    <div>
      <van-pull-refresh v-model="isLoading" success-text="刷新成功" @refresh="onRefresh">
        <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
          <div v-for="(item,index) in jobs" :key="index" class="employmentTraining-training-job"
            @click="$router.push({path:'/work/employmentTraining/jobDetails',query:{id:item.positionId}})">
            <p>
              <span class="employmentTraining-training-jobName">{{
              item.subject
            }}</span>
              <span class="employmentTraining-training-salary">{{
              item.creationDate
            }}</span>
            </p>
            <p class="employmentTraining-training-company">
              {{ item.companyName }}
            </p>
            <p class="employmentTraining-training-address">
              <span>{{ item.salaryName }}</span>
            </p>
          </div>
        </van-list>
      </van-pull-refresh>
    </div>
  </div>
</template>
<script>
  import mine from "../../../../controller/mine";
  import constant from "@/controller/constant.js";
  export default {
    name: "feedBack",
    components: {},
    data() {
      return {
        loading: false,
        finished: false,
        isLoading: false,
        count: 1,
        jobs: []
      };
    },
    computed: {},
    created() {},
    mounted() {},
    methods: {
      onLoad() {
        this.getInfo();
      },
      onRefresh() {
        this.jobs = []
        this.count = 1
        this.getInfo();
      },
      getInfo() {
        let data = {
          curPage: this.count,
          pageSize: (this.count) * 10
        };
        mine.training_positionApply_pageByCurrentUser(data).then(res => {
          if (res.code === "0") {
            if (
              (res.datas && res.datas.records.length === 0) ||
              res.datas === null
            ) {
              this.loading = false;
              this.isLoading = false;
              this.finished = true;
              return;
            }
            this.jobs = [...this.jobs, ...res.datas.records];
            this.$nextTick(() => {
              this.loading = false;
              this.isLoading = false;
            });
            if (res.datas.records.length < (this.count) * 10) {
              this.finished = true;
            }
          } else {
            if (res && res.msg) {
              this.$toast(res.msg);
            } else {
              this.$toast(constant.unusualMsg);
            }
          }
        });
      },
      back() {
        this.$router.go(-1);
      }
    }
  };
</script>
<style lang="scss" scoped>
  .employmentTraining-training-job {
    padding: 20px;
    border-bottom: 1px solid #ccc;

    >p {
      height: 30px;
      line-height: 30px;
    }
  }

  .employmentTraining-training-jobName {
    font-size: 16px;
    font-weight: bold;
  }

  .employmentTraining-training-salary {
    float: right;
    font-size: 14px;
    font-weight: 200;
    opacity: 0.5;
  }

  .employmentTraining-training-company {
    font-size: 14px;
    color: #666666;
  }

  .employmentTraining-training-address {
    >span {
      color: #dc4630;
      font-size: 14px;
      font-weight: 600;
    }
  }
</style>